package org.axeidls;

import org.axe.constant.ConfigConstant;
import org.axe.jetty.AxeStartWeb;
import org.axe.jetty.config.JettyConfig;
import org.axe.util.AxeProperties;
import org.axe.util.LogUtil;
import org.axe.util.StringUtil;

/**
 * @author CaiDdongyu
 * @date 2021-7-30
 */
public class Application {

	public static void main(String ...args) {
		try {
			//加载默认resouce下的项目配置文件
			AxeProperties.loadYml("idls.yml");
			AxeProperties.loadJison("config.jison");
			
			Boolean nvgt = AxeProperties.getBoolean("axe.nvgt.enable",true);
			if(!nvgt) {
				String exclude = AxeProperties.getProperty(ConfigConstant.AXE_BASE_PACKAGE_EXCLUDE);
				if(StringUtil.isNotEmpty(exclude)) {
					exclude = exclude+",";
				}else {
					exclude = "";
				}
				exclude = exclude+"org.axe.extra.nvgtc.client";//排除掉nvgtc包
				AxeProperties.loadArgs(new String[] {ConfigConstant.AXE_BASE_PACKAGE_EXCLUDE+"="+exclude});
			}else {
				//强制单例注册
				AxeProperties.loadArgs(new String[] {"axe.nvgt.force-single=true"});
			}
			JettyConfig config = new JettyConfig(AxeProperties.getInt("server.api-port"));
			AxeStartWeb.startServer(config.setCors());
		} catch (Exception e) {
			LogUtil.error(e,"启动失败");
			System.exit(0);
		}

	}

}
